import tkinter as tk
from tkinter import ttk, messagebox
from tkinter.font import Font
import os


def toggle_topmost():
    """切换窗口置顶状态"""
    is_topmost = topmost_var.get()
    root.attributes('-topmost', is_topmost)
    status_label.config(text="窗口置顶: " + ("是" if is_topmost else "否"))


def release_control1():
    """解除控制1的按钮功能"""
    os.system("start jpk.exe")


def release_control2():
    """解除控制2的按钮功能"""
    os.system("start jjk.exe")


# 创建主窗口
root = tk.Tk()
root.title("控制面板")
root.geometry("400x500")
root.resizable(False, False)

# 设置主题风格
style = ttk.Style()
style.theme_use('clam')  # 可以选择: 'clam', 'alt', 'default', 'classic'

# 自定义字体
title_font = Font(family="微软雅黑", size=12, weight="bold")
button_font = Font(family="微软雅黑", size=10)

# 标题标签
title_label = ttk.Label(
    root,
    text="控制面板",
    font=title_font,
    foreground="#2c3e50",
    padding=(0, 10, 0, 20)
)
title_label.pack()

# 置顶选择框
top_frame = ttk.Frame(root, padding=(20, 0))
top_frame.pack(pady=10)

topmost_var = tk.BooleanVar(value=False)
topmost_check = ttk.Checkbutton(
    top_frame,
    text="窗口置顶",
    variable=topmost_var,
    command=toggle_topmost,
    style='Toolbutton'
)
topmost_check.pack(side=tk.LEFT)

# 状态标签
status_label = ttk.Label(
    top_frame,
    text="窗口置顶: 否",
    foreground="#7f8c8d",
    padding=(10, 0)
)
status_label.pack(side=tk.LEFT)

# 按钮框架
button_frame = ttk.Frame(root, padding=20)
button_frame.pack(pady=20)

# 解除控制1按钮
release_btn1 = ttk.Button(
    button_frame,
    text="解除屏幕控制",
    command=release_control1,
    style='Accent.TButton'
)
release_btn1.pack(pady=10, ipadx=20, ipady=8)

# 解除控制2按钮
release_btn2 = ttk.Button(
    button_frame,
    text="解除键盘控制",
    command=release_control2,
    style='Accent.TButton'
)
release_btn2.pack(pady=10, ipadx=20, ipady=8)

# 底部信息标签
info_label = ttk.Label(
    root,
    text="© 2023 控制面板 | 版本 1.0",
    foreground="#95a5a6",
    padding=(0, 20)
)
info_label.pack()

# 自定义按钮样式
style.configure('Accent.TButton',
                font=button_font,
                foreground='white',
                background='#3498db',
                bordercolor='#3498db',
                focuscolor='#3498db',
                padding=10)
style.map('Accent.TButton',
          foreground=[('pressed', 'white'), ('active', 'white')],
          background=[('pressed', '#2980b9'), ('active', '#2980b9')])

# 运行主循环
root.mainloop()
